class PostsController < ApplicationController
  def index
  	@posts = Post.all
    @title = "Display all posts"
  end

  def new
  	@post = Post.new
    @title = "Add new posts"
  end

  def create
    # render :text => params[:post]

    @post = Post.new(post_params)
    if @post.save
      redirect_to posts_path
    else
      render action: "new"
    end
  end

  private
  def post_params
    params.require(:post).permit(:name, :content)
  end


end
